<% layout('/layouts/default.html', {title: '出货、入货、结账、充值界面', libs: ['validate']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa fa-list-alt"></i> ${text(record.isNewRecord ? '出货/入货' : '编辑record')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${record}" action="${ctx}/vip/record/update" method="post" onsubmit="handle()" class="form-horizontal">
		<#form:hidden path="memberId"/>
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('会员姓名')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input  value="${member.name}" maxlength="32" disabled="disabled"  class="form-control required"/>
							</div>
						</div>
					</div>


				</div>
				<div class="row" id="type">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="type" dictType="vip_record_type" disabled="disabled" id="typeId" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row" id="checkOutMoney">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('结账金额')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input value="${member.balance}" disabled="disabled" class="form-control required number"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row" id="project">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('项目')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="projectId" items="${projectList}" itemLabel="name" itemValue="id" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row" id="payType">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('支付方式')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:select path="payType" dictType="vip_pay_type" id="typeId" class="form-control required" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('金额')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="money" class="form-control required number"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('vip:record:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
	$("#inputForm").validate({
		submitHandler: function(form){
			js.ajaxSubmitForm($(form), function(data){
				js.showMessage(data.message);
				if(data.result == Global.TRUE){
					js.closeCurrentTabPage(function(contentWindow){
						contentWindow.page();
					});
				}
			}, "json");
		}
	});
	$(document).ready(function(){
		if(${record.type}==4||${record.type}==3){
			document.getElementById("project").remove();
		}else{
            document.getElementById("payType").remove();
		}
		if(${record.type}!=3){
            document.getElementById("checkOutMoney").remove();
		}

		<!--提交表单前删除type disable属性，不然传不了值-->
		$("#typeId").click(function(){
			alert("此处不可选择！");
			return false;
		});
	});

	function handle() {
		$("#typeId").removeAttr("disabled");
	}
</script>